//
//  FahuoDetailViewController.m
//  specialine
//
//  Created by 往返网络 on 17/3/7.
//  Copyright © 2017年 com. All rights reserved.
//

#import "FahuoDetailViewController.h" //发货运单详情界面，没有操作（收藏后期加入）／中转／外包详情也用此界面，公司名称的值有所不同

#define begin_x  24.0/W_BASE*SCREEN_W
#define spaceview_h 70.0/H_BASE*SCREEN_H

#define return_tag 1001
#define search_tag 1002 //运单的右上角，后期增加收藏功能
#define docudetail_tag 1003   //切换发货界面
#define docufollow_tag 1004  //切换到货界面
//定义运单详情URL
#define URL_DETAIL [NSString stringWithFormat:@"%@/Appcustomernewer/Order/orderInfo?type=get",BASE_URL]

#define URL_FOLLOW [NSString stringWithFormat:@"%@/Appcustomernewer/Order/orderFollow?type=get",BASE_URL]

@interface FahuoDetailViewController ()<UIScrollViewDelegate>
@property (nonatomic,strong)AFHTTPSessionManager* manger;
@property (nonatomic, strong)NSMutableArray * followarr;

@end

@implementation FahuoDetailViewController

{
    
    UIButton * docudetailbtn; //运单详情
    
    UIButton * docudefollowbtn; //运单跟踪

    UIButton * scrollbtn; //滚动条

    UIScrollView * scrollview; //页面主体
    
    UIScrollView * detailscrollview; //运单详情页面
    
    UIScrollView * followscrollview; //运单跟踪页面

    //运单view
    
    UIView * docuview;
    
    UILabel * doculabel; //运单号
    UILabel * startplace; //  起始地
    UILabel * endplace;  //目的地
    UILabel * nameandTime; //发货人以及时间
    UILabel * company; // 公司
    
    
    //收发人
    
    UIView * shoufarenview;
    
    UILabel * name;     //姓名
    UILabel * phone;    //电话 + 事件，拨打电话
    UILabel * address;    //地址
    UILabel * shouhuoname;     //收货人姓名 ＋事件，拨打电话
    UILabel * shouhuophone;    //收货人电话
    UILabel * shouhuoaddress;    //收货人地址
    
    
    //货物信息
    
    UIView * goodsview;
    
    UILabel * goodsname;
    UILabel * num;
    UILabel * weight;
    UILabel * package;
    UILabel * tiji;
    
    UILabel * goodsname2;
    UILabel * num2;
    UILabel * weight2;
    UILabel * package2;
    UILabel * tiji2;

    UILabel * goodsname3;
    UILabel * num3;
    UILabel * weight3;
    UILabel * package3;
    UILabel * tiji3;
    
    //增值服务
    
    UIView * zengzhiserver;
    UILabel * shouhuostyle; //提货方式
    UILabel * shouhuofangshi; //收货方式
    UILabel * daishougoodsprice; //代收货款
    UILabel * daishouprice;  //代收金额
    UILabel * wuliubao; //物流保
    UILabel * goodsprice; //货物价值
    UILabel * baoxianprice; //保险金额
    
    //费用明细

    UIView  * feiyongview;
    
    UILabel * yunfei; //运费
    UILabel * xianfu; //先付
    UILabel * qianfu; //欠付
    UILabel * huidan; //回单
    UILabel * huifu; //回付
    UILabel * daofu; //到付
    
    //返款
    
    UIView * fankuanview;
    
    UILabel  * fankuan; //返款
    UILabel * qianfan; //欠返
    
    
    //备注
    
    UIView * remarkview;
    UILabel * remark; //备注
    
    
    //自提
    
    UIView * zitiview;
    
    
    
    //运单跟踪view
    
    UIView * follow_docuview;
    
    UILabel * follow_doculabel; //运单号
    UILabel * follow_startplace; //  起始地
    UILabel * follow_endplace;  //目的地
    UILabel * follow_nameandTime; //发货人以及时间
    UILabel * follow_company; // 公司

    
    NSString * token;
    
  
    CGFloat maxY;

}

- (NSMutableArray *)followarr {
    if (!_followarr) {
        _followarr = [[NSMutableArray alloc] init];
    }
    return _followarr;
}


- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    //运单详情
    [self loadDatadetail];
    
    //运单跟踪
    [self loadDatafollow];
    
    
    [self createUI];
    
    
    // Do any additional setup after loading the view.
}


- (void)loadDatadetail{
    
    
    
    NSUserDefaults * userdefalut = [NSUserDefaults standardUserDefaults];
    
    token = [userdefalut objectForKey:USER_TOCKE];
    
    
    NSString * url = [NSString stringWithFormat:@"%@&token=%@&oid=%@",URL_DETAIL,token,self.oid];
    
    NSLog(@"运单详情 url %@",url);
    
    [self.manger GET:url parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject) {
            
            NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
            
            NSInteger code = [dict[@"code"]integerValue];
            
            
            if (code == 0) {
                
                
                NSDictionary * data = dict[@"data"];
                
                doculabel.text = [NSString stringWithFormat:@"运单号: %@ [%@]",data[@"order_id"],data[@"orderstate"]];
                startplace.text = [NSString stringWithFormat:@"%@",data[@"start_place"]];
                endplace.text = [NSString stringWithFormat:@"%@",data[@"end_place"]];
                nameandTime.text = [NSString stringWithFormat:@"%@ %@",data[@"create_order_name"],data[@"created_time"]];
                company.text = [NSString stringWithFormat:@"%@",data[@"company_name"]];
                name.text = [NSString stringWithFormat:@"发货人: %@",data[@"from_person"]];
                address.text = [NSString stringWithFormat:@"地址: %@",data[@"from_address"]];
                phone.text = [NSString stringWithFormat:@"%@",data[@"from_mobile"]];
                shouhuoname.text = [NSString stringWithFormat:@"收货人: %@",data[@"to_person"]];
                shouhuoaddress.text = [NSString stringWithFormat:@"地址: %@",data[@"to_address"]];
                shouhuophone.text  = [NSString stringWithFormat:@"%@",data[@"to_mobile"]];
            
                goodsname.text = [NSString stringWithFormat:@"货物: %@",data[@"goods_name1"]];
                
                num.text =[NSString stringWithFormat:@"数量: %@",data[@"goods_num1"]]; //@"数量: 1545箱";
                package.text = [NSString stringWithFormat:@"包装: %@",data[@"goods_package1"]];// @"包装: 纸箱";
                weight.text = [NSString stringWithFormat:@"重量: %@",data[@"goods_weight1"]]; // @"重量: 1000克";
                tiji.text = [NSString stringWithFormat:@"体积: %@",data[@"goods_volume1"]];// @"体积: 200平方米";

                goodsname2.text = [NSString stringWithFormat:@"货物: %@",data[@"goods_name2"]];
                
                num2.text =[NSString stringWithFormat:@"数量: %@",data[@"goods_num2"]]; //@"数量: 1545箱";
                package2.text = [NSString stringWithFormat:@"包装: %@",data[@"goods_package2"]];// @"包装: 纸箱";
                weight2.text = [NSString stringWithFormat:@"重量: %@",data[@"goods_weight2"]]; // @"重量: 1000克";
                tiji2.text = [NSString stringWithFormat:@"体积: %@",data[@"goods_volume2"]];// @"体积: 200平方米";
                
                goodsname3.text = [NSString stringWithFormat:@"货物: %@",data[@"goods_name3"]];
                
                num3.text =[NSString stringWithFormat:@"数量: %@",data[@"goods_num3"]]; //@"数量: 1545箱";
                package3.text = [NSString stringWithFormat:@"包装: %@",data[@"goods_package1"]];// @"包装: 纸箱";
                weight3.text = [NSString stringWithFormat:@"重量: %@",data[@"goods_weight3"]]; // @"重量: 1000克";
                tiji3.text = [NSString stringWithFormat:@"体积: %@",data[@"goods_volume3"]];// @"体积: 200平方米";
                

                shouhuostyle.text = [NSString stringWithFormat:@"%@",data[@"receiptmethod"]];
                
                wuliubao.text = [NSString stringWithFormat:@"物流保: %@",data[@"insurancestate"]];

                goodsprice.text = [NSString stringWithFormat:@"货物价值: %@",data[@"goods_value"]];

                daishougoodsprice.text = [NSString stringWithFormat:@"代收货款: %@(5％费率)",data[@"collectionstate"]];
                if ([data[@"collectionstate"]isEqualToString:@"否"]) {
                    daishougoodsprice.text = [NSString stringWithFormat:@"代收货款: %@",data[@"collectionstate"]];

                }
                
//                baoxianprice.text = [NSString stringWithFormat:@"保险金额: %@元",data[@"insurance_cost"]];
                
                yunfei.text = [NSString stringWithFormat:@"运费: %@元",data[@"fee"]];
                
                xianfu.text =[NSString stringWithFormat:@"现付: %@元",data[@"cash"]];
                
                daofu.text = [NSString stringWithFormat:@"到付: %@元",data[@"to_pay"]];
                qianfu.text =[NSString stringWithFormat:@"欠付: %@元",data[@"oth_fee"]];
                
                qianfan.text = [NSString stringWithFormat:@"欠返: %@元",data[@"owed"]]; // @"欠返: 1000元";
                remark.text = [NSString stringWithFormat:@"%@",data[@"remark"]];
                
//                huidan.text = [NSString stringWithFormat:@"回单: %@份",data[@"receipt_num"]]; //份数
                huidan.text = [NSString stringWithFormat:@"回单(%@份): %@元",data[@"receipt_num"],data[@"receipt_fee"]]; //份数
                daishouprice.text =[NSString stringWithFormat:@"代收金额: %@元",data[@"collection"]];
//                huifu.text =[NSString stringWithFormat:@"回付: %@元",data[@"receipt_fee"]];
                fankuan.text =[NSString stringWithFormat:@"返款: %@元",data[@"rebate"]];//@"返款: 100元";
                
                
                
                
                
                
                

            }else{
                
                
                
                ALERT(@"提示", dict[@"info"], self, @"确定", nil);
                
            }
            
            
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
        
        ALERT(@"提示", @"网络请求失败", self, @"确定", nil);
        
    }];
    
    
}


- (void)loadDatafollow{
    
    NSUserDefaults * userdefalut = [NSUserDefaults standardUserDefaults];
    
    token = [userdefalut objectForKey:USER_TOCKE];
    
    NSString * url = [NSString stringWithFormat:@"%@&token=%@&oid=%@",URL_FOLLOW,token,self.oid];
    
    NSLog(@"运单跟踪 url %@",url);
    
    [self.manger GET:url parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject) {
            
            NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
            
            NSInteger code = [dict[@"code"]integerValue];
            
            
            if (code == 0) {
                
                NSDictionary * data = dict[@"data"];
                
                follow_doculabel.text =[NSString stringWithFormat:@"运单号: %@ [%@]",data[@"order_id"],data[@"orderstate"]];
                
                follow_nameandTime.text =[NSString stringWithFormat:@"%@ %@",data[@"create_order_name"],data[@"created_time"]];
                                          
                follow_endplace.text =[NSString stringWithFormat:@"%@",data[@"start_place"]];
                
                follow_startplace.text =[NSString stringWithFormat:@"%@",data[@"end_place"]];
            
                follow_company.text = [NSString stringWithFormat:@"%@",data[@"company_name"]];

                self.followarr = data[@"followArr"];
                
                [self addFollowViews];
                
            }else{
                
                
                
                ALERT(@"提示", dict[@"info"], self, @"确定", nil);
                
            }
            
            
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
        
        ALERT(@"提示", @"网络请求失败", self, @"确定", nil);
        
    }];
    
    
}

- (void)createUI{


    [self setTitleView]; //设置搜索条及华东的view
    
    
    [self createScrollwithSmallScrollview]; //创建详情页面，跟踪页面
    
    

}

#pragma mark -- -- - - -- - - - -  设置表头 - -- - - - - - -
- (void)setTitleView{
    
    
    UIView * titleview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, 128.0/1334*SCREEN_H)];
    
    titleview.backgroundColor = COLORRGBA(7, 24, 57, 1);
    
    [self.view addSubview:titleview];
    
    
    float fontsize = 18;
    
    fontsize = SCREEN_H < 667 ? 16 : 20 ;
    
    if (SCREEN_H == 667) {
        
        fontsize = 18;
        
    }
    
    UIFont * iconfont = [UIFont fontWithName:@"iconfont" size:fontsize];
    
    
    UIButton * leftlable  = [[UIButton alloc]initWithFrame:CGRectMake(0, 20+14.0/1334*SCREEN_H, 80.0/W_BASE*SCREEN_W, 60.0/1334.0*SCREEN_H)];
    
    [leftlable setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    leftlable.tag = return_tag;
    
    leftlable.titleLabel.font = [UIFont fontWithName:@"iconfont" size:fontsize+3];
    
    [leftlable setTitle:@"\U0000e697" forState:UIControlStateNormal];
    
    
    
    [leftlable.titleLabel setTextAlignment:NSTextAlignmentCenter];
    
    [leftlable addTarget:self action:@selector(enterClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [titleview addSubview:leftlable];
    
    
    UILabel * titlelab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_W*0.5-75.0/W_BASE*SCREEN_W, CGRectGetMinY(leftlable.frame), 150.0/W_BASE*SCREEN_W, CGRectGetHeight(leftlable.frame))];
    
    titlelab.textAlignment = NSTextAlignmentCenter;
    
    titlelab.textColor = [UIColor whiteColor];
    
    titlelab.font = [UIFont systemFontOfSize:fontsize - 1];
    
    titlelab.text = @"运单详情";
    
    
    [titleview addSubview:titlelab];
    
    //收藏等额外功能
    
    UIButton * rightbtn = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_W - CGRectGetWidth(leftlable.frame), CGRectGetMinY(titlelab.frame), CGRectGetWidth(leftlable.frame), CGRectGetHeight(leftlable.frame))];
    
    [rightbtn setTitle:@"\U0000e611" forState:UIControlStateNormal];
    
    rightbtn.titleLabel.font = iconfont;
    
    [rightbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [rightbtn addTarget:self action:@selector(enterClick:) forControlEvents:UIControlEventTouchUpInside];
    
    rightbtn.tag = search_tag;
    
  //  [titleview addSubview:searchbtn];
    
    
    //创建 切换btn
    
    UIView * backview = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(titleview.frame), SCREEN_W, 80.0/H_BASE*SCREEN_H)];
    
    backview.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:backview];
    
    
    UIView * breakline = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_W * 0.5, 10.0/H_BASE*SCREEN_H, 1.0/W_BASE*SCREEN_W, 60.0/H_BASE*SCREEN_H)];
    
    breakline.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [backview addSubview:breakline];
    
    
    docudetailbtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W*0.5, CGRectGetHeight(backview.frame))];
    
    [docudetailbtn setTitle:@"运单详情" forState:UIControlStateNormal];
    
    docudetailbtn.titleLabel.font = [UIFont systemFontOfSize:fontsize - 5];
    
    [docudetailbtn addTarget:self action:@selector(enterClick:) forControlEvents:UIControlEventTouchUpInside];
    
    docudetailbtn.tag = docudetail_tag;
    
    [docudetailbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [backview addSubview:docudetailbtn];
    
    
    docudefollowbtn = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_W * 0.5, 0, SCREEN_W *0.5, CGRectGetHeight(backview.frame))];
    
    [docudefollowbtn setTitle:@"运单跟踪" forState:UIControlStateNormal];
    
    [docudefollowbtn addTarget:self action:@selector(enterClick:) forControlEvents:UIControlEventTouchUpInside];
    
    docudefollowbtn.titleLabel.font = [UIFont systemFontOfSize:fontsize - 5];
    
    [docudefollowbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    docudefollowbtn.tag = docufollow_tag;
    
    
    [backview addSubview:docudefollowbtn];
    
    scrollbtn = [[UIButton alloc]initWithFrame:CGRectMake(130.0/W_BASE*SCREEN_W, CGRectGetHeight(backview.frame)-4.0/H_BASE*SCREEN_H, 110.0/W_BASE*SCREEN_W, 4.0/H_BASE*SCREEN_H)];
    
    [scrollbtn setBackgroundColor:COLORRGBA(51, 204, 102, 1)];
    
    [backview addSubview:scrollbtn];
    

    
    //判断当前为详情界面/跟踪界面
    
    if ([self.isDetail isEqualToString:@"NO"]) {
        
        
        titlelab.text = @"运单跟踪";
        
        CGRect rect = CGRectMake(SCREEN_W * 0.5+ 130.0/W_BASE*SCREEN_W, CGRectGetMinY(scrollbtn.frame), CGRectGetWidth(scrollbtn.frame), CGRectGetHeight(scrollbtn.frame));
        
        scrollbtn.frame = rect;
        
        [docudefollowbtn setTitleColor:COLORRGBA(81, 168, 255, 1) forState:UIControlStateNormal];
        
        scrollbtn.frame = CGRectMake(SCREEN_W*0.5+130.0/W_BASE*SCREEN_W, CGRectGetHeight(backview.frame)-4.0/H_BASE*SCREEN_H, 110.0/W_BASE*SCREEN_W, 4.0/H_BASE*SCREEN_H);
        

        
    }
    

    
}

- (void)createScrollwithSmallScrollview{
    
    
    
    scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 208.0/H_BASE*SCREEN_H, SCREEN_W, SCREEN_H - 208.0/H_BASE*SCREEN_H)];
    
    scrollview.contentSize = CGSizeMake(SCREEN_W*2, SCREEN_H - 208.0/H_BASE*SCREEN_H);
    
    scrollview.showsVerticalScrollIndicator = NO;
    
    scrollview.showsHorizontalScrollIndicator = NO;
    
    
    
    scrollview.pagingEnabled = YES;
    
    scrollview.delegate = self;
    
    [self.view addSubview:scrollview];
    
    UIView * headerview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W*2, 30.0/H_BASE*SCREEN_H)];
    
    headerview.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    
    [scrollview addSubview:headerview];
    
    
     //添加2个小scrollview
    
    [self createDetailScrollview];
    
    [self createFollowScrollview];
    
    //判断当前显示哪个页面
    
    if ([_isDetail isEqualToString:@"NO"]) {
        
        
        scrollview.contentOffset = CGPointMake(SCREEN_W, 0);
        
    }
   
    
}

#pragma mark - -- - - - - -  运单详情界面－ －－ － － －－ － － －

- (void)createDetailScrollview{

    
    float fontsize = 14;
    
    fontsize = SCREEN_H < 667 ? 12 : 16;
    
    if (SCREEN_H == 667) {
        
        fontsize = 14;
    }

    
    detailscrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 14.0/H_BASE*SCREEN_H, SCREEN_W, CGRectGetHeight(scrollview.frame))];
    
    detailscrollview.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [scrollview addSubview:detailscrollview];
    
    detailscrollview.showsVerticalScrollIndicator = NO;
    
    detailscrollview.showsHorizontalScrollIndicator = NO;
    
    detailscrollview.pagingEnabled = YES;
    
    detailscrollview.delegate = self;
    
    detailscrollview.contentSize = CGSizeMake(SCREEN_W, (1760.0+100.0+430.0-166.0-150.0)/H_BASE*SCREEN_H);

    //运单view
    
    docuview = [[UIView alloc]initWithFrame:CGRectMake(6.0/W_BASE*SCREEN_W, 0, 744.0/W_BASE*SCREEN_W, 204.0/H_BASE*SCREEN_H)];
    
//    docuview.backgroundColor = [UIColor yellowColor];
    
    [detailscrollview addSubview:docuview];
    
    docuview.layer.cornerRadius = 2;
    
    docuview.clipsToBounds = YES;
    
    UIImageView * im = [[UIImageView alloc]initWithFrame:docuview.bounds];
    
    im.image = [UIImage imageNamed:@"docuback.png"];
    
    [docuview addSubview:im];
    
    doculabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0/W_BASE*SCREEN_W, 14.0/H_BASE*SCREEN_H, CGRectGetWidth(docuview.frame) - 40.0/W_BASE*SCREEN_W, 60.0/H_BASE*SCREEN_H)];
    
    doculabel.textColor = [UIColor whiteColor];
    
    doculabel.font = [UIFont boldSystemFontOfSize:fontsize];
    
    [docuview addSubview:doculabel];
    
    UIImageView * iconimage = [[UIImageView alloc]initWithFrame:CGRectMake(22.0/W_BASE*SCREEN_W, CGRectGetMaxY(doculabel.frame)+24.0/H_BASE*SCREEN_H, 18.0/W_BASE*SCREEN_W, 64.0/H_BASE*SCREEN_H)];
    
    iconimage.image = [UIImage imageNamed:@"startline.png"];
    
    [docuview addSubview:iconimage];
    
    startplace = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(iconimage.frame)+12.0/W_BASE*SCREEN_W, CGRectGetMaxY(doculabel.frame)+5.0/H_BASE*SCREEN_H, 200.0/W_BASE*SCREEN_W, 60.0/H_BASE*SCREEN_H)];
    
    startplace.font = [UIFont systemFontOfSize:fontsize - 1];
    
    [docuview addSubview:startplace];
    
    endplace = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(iconimage.frame)+12.0/W_BASE*SCREEN_W, CGRectGetMaxY(startplace.frame)-10.0/H_BASE*SCREEN_H, 200.0/W_BASE*SCREEN_W, 60.0/H_BASE*SCREEN_H)];
    
    endplace.font = [UIFont systemFontOfSize:fontsize - 1];
    
    [docuview addSubview:endplace];
    
    nameandTime = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(startplace.frame)+ 160.0/W_BASE*SCREEN_W, CGRectGetMinY(startplace.frame), 305.0/W_BASE*SCREEN_W, CGRectGetHeight(startplace.frame))];

    
    nameandTime.font = [UIFont systemFontOfSize:fontsize - 1];
    
    [docuview addSubview:nameandTime];
    
    nameandTime.textAlignment = NSTextAlignmentRight;
    
    nameandTime.textColor = COLORRGBA(204, 204, 204, 1);
    
    company = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(startplace.frame)+ 160.0/W_BASE*SCREEN_W, CGRectGetMinY(endplace.frame), 305.0/W_BASE*SCREEN_W, CGRectGetHeight(startplace.frame))];
    
//    company.backgroundColor = [UIColor purpleColor];
    
    
    company.font = [UIFont systemFontOfSize:fontsize - 1];
    
    [docuview addSubview:company];
    
    company.textAlignment = NSTextAlignmentRight;
    
    
    
    //收发人VIEW
    
    shoufarenview = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(docuview.frame), SCREEN_W, 287.0/H_BASE*SCREEN_H)];
    
    shoufarenview.backgroundColor = [UIColor whiteColor];
    
    [detailscrollview addSubview:shoufarenview];
    
    UIView * titleview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, spaceview_h)];
    
    titleview.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [shoufarenview addSubview:titleview];
    
    
    UILabel * titlelab = [[UILabel alloc]initWithFrame:CGRectMake(24.0/W_BASE*SCREEN_W, 0, SCREEN_W, spaceview_h)];
    
    [shoufarenview addSubview:titlelab];
    
    titlelab.font = [UIFont systemFontOfSize:fontsize - 1];
    
    titlelab.text = @"收发人";
    
    name = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(titlelab.frame), CGRectGetMaxY(titlelab.frame)+16.75/H_BASE*SCREEN_H, 270.0/W_BASE*SCREEN_W, 37.5/H_BASE*SCREEN_H)];
    
    name.font = [UIFont systemFontOfSize:fontsize];
    
    [shoufarenview addSubview:name];
    
    address = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(name.frame), CGRectGetMaxY(name.frame), SCREEN_W - begin_x*2, CGRectGetHeight(name.frame))];
    
    address.font = [UIFont systemFontOfSize: fontsize - 2];
    
    [shoufarenview addSubview:address];
    
    UIView * spaceview = [[UIView alloc]initWithFrame:CGRectMake(begin_x, 178.5/H_BASE*SCREEN_H, SCREEN_W - begin_x*2, 1)];
    
    spaceview.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [shoufarenview addSubview:spaceview];
    
    phone = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(nameandTime.frame), CGRectGetMinY(name.frame), CGRectGetWidth(nameandTime.frame) -30.0/W_BASE*SCREEN_W , CGRectGetHeight(name.frame))];
    
    phone.textAlignment = NSTextAlignmentRight;
    
    phone.font = [UIFont systemFontOfSize:fontsize];
    
    [shoufarenview addSubview:phone];
    
    UILabel * moible1 = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(phone.frame), CGRectGetMinY(phone.frame), 30.0/W_BASE*SCREEN_W, 30.0/W_BASE*SCREEN_W)];
    
    moible1.textColor = COLORRGBA(38, 146, 255, 1);
    
    [shoufarenview addSubview:moible1];
    
    moible1.font = [UIFont fontWithName:@"iconfont" size:fontsize];
    
    moible1.text = @"\U0000e668";
    
    
    shouhuoname = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(name.frame), CGRectGetMinY(spaceview.frame)+16.75/H_BASE*SCREEN_H, CGRectGetWidth(name.frame), CGRectGetHeight(name.frame))];
    
    shouhuoname.font = [UIFont systemFontOfSize:fontsize];
    
    [shoufarenview addSubview:shouhuoname];
    
    shouhuoaddress = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(address.frame), CGRectGetMaxY(shouhuoname.frame), CGRectGetWidth(address.frame), CGRectGetHeight(shouhuoname.frame))];
    
    
    shouhuoaddress.font = [UIFont systemFontOfSize:fontsize - 2];
    
    [shoufarenview addSubview:shouhuoaddress];
    
    
    shouhuophone = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(phone.frame), CGRectGetMinY(shouhuoname.frame), CGRectGetWidth(phone.frame), CGRectGetHeight(phone.frame))];
    
    
    shouhuophone.font = [UIFont systemFontOfSize:fontsize];
    
    [shoufarenview addSubview:shouhuophone];
    
    shouhuophone.textAlignment = NSTextAlignmentRight;
    
    UILabel * moible2 = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(moible1.frame), shouhuophone.frame.origin.y, CGRectGetWidth(moible1.frame), CGRectGetHeight(moible1.frame))];
    
    moible2.font = [UIFont fontWithName:@"iconfont" size:fontsize];
    
    moible2.text = @"\U0000e668";
    
    moible2.textColor = COLORRGBA(255, 102, 102, 1);
    
    [shoufarenview addSubview:moible2];
    
    UIButton * phonebtn = [[UIButton alloc]initWithFrame:CGRectMake(CGRectGetMinX(nameandTime.frame), CGRectGetMinY(name.frame), CGRectGetWidth(nameandTime.frame) , CGRectGetHeight(name.frame))];
    
    [phonebtn addTarget:self action:@selector(phoneNow:) forControlEvents:UIControlEventTouchUpInside];
    

    UIButton * phonebtn2 = [[UIButton alloc]initWithFrame:CGRectMake(CGRectGetMinX(phonebtn.frame), CGRectGetMinY(shouhuoname.frame), CGRectGetWidth(nameandTime.frame), CGRectGetHeight(phone.frame))];
    
    
    [phonebtn2 addTarget:self action:@selector(phoneNow:) forControlEvents:UIControlEventTouchUpInside];
    
    phonebtn.tag = 7000;
    
    phonebtn2.tag = 8000;
    
    
    [shoufarenview addSubview:phonebtn];
    
    [shoufarenview addSubview:phonebtn2];
    
    
    
    
    //货物信息
    
    goodsview = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(shoufarenview.frame), SCREEN_W, 285.0/H_BASE*SCREEN_H+215.0/H_BASE*SCREEN_H*2)];
    
    goodsview.backgroundColor = [UIColor whiteColor];
    
    [detailscrollview addSubview:goodsview];
    
    
    UIView * titleview1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, spaceview_h)];
    
    titleview1.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [goodsview addSubview:titleview1];
    
    UILabel * titlelabe = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, 0, 200.0/W_BASE*SCREEN_W, spaceview_h)];
    
    titlelabe.text = @"货物信息";
    
    titlelabe.font = [UIFont systemFontOfSize:fontsize - 1];
    
    [goodsview addSubview:titlelabe];
    
    
    goodsname = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(titlelabe.frame), 370.0/W_BASE*SCREEN_W, 82.0/H_BASE*SCREEN_H)];
    
  
    goodsname.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:goodsname];
    
    
    UIView * spaceview1 = [[UIView alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(goodsname.frame), SCREEN_W - begin_x*2, 1)];
    
    spaceview1.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [goodsview addSubview:spaceview1];
    
    num = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(spaceview1.frame)+16.75/H_BASE*SCREEN_H, 250.0/W_BASE*SCREEN_W, 46.75/H_BASE*SCREEN_H)];
    
    
    num.textColor = COLORRGBA(153, 153, 153, 1);

    num.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:num];
    
    package = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(num.frame)+5.0/H_BASE*SCREEN_H, CGRectGetWidth(num.frame), CGRectGetHeight(num.frame))];
    
    
    package.textColor = COLORRGBA(153, 153, 153, 1);

    package.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:package];
    
    
    weight = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(num.frame)+90.0/W_BASE*SCREEN_W, CGRectGetMinY(num.frame), 300.0/W_BASE*SCREEN_W, CGRectGetHeight(num.frame))];
    
    
    weight.textColor = COLORRGBA(153, 153, 153, 1);
    
    weight.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:weight];
    
    
    
    tiji = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(weight.frame), CGRectGetMaxY(weight.frame), CGRectGetWidth(weight.frame), CGRectGetHeight(weight.frame))];
    
    
    tiji.font = [UIFont systemFontOfSize:fontsize];
    
    tiji.textColor = COLORRGBA(153, 153, 153, 1);

    [goodsview addSubview:tiji];
    
    UIView * breakline1 = [[UIView alloc]initWithFrame:CGRectMake(0, 285.0/H_BASE*SCREEN_H, SCREEN_W, 1)];
    
    breakline1.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [goodsview addSubview:breakline1];
    
    
//    UILabel * goodsname2;
//    UILabel * num2;
//    UILabel * weight2;
//    UILabel * package2;
//    UILabel * tiji2;

    goodsname2 = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(breakline1.frame), 370.0/W_BASE*SCREEN_W, 82.0/H_BASE*SCREEN_H)];
    
    
    goodsname2.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:goodsname2];
    
    
    UIView * spaceview5 = [[UIView alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(goodsname2.frame), SCREEN_W - begin_x*2, 1)];
    
    spaceview5.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [goodsview addSubview:spaceview5];

    num2 = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(spaceview5.frame)+16.75/H_BASE*SCREEN_H, 250.0/W_BASE*SCREEN_W, 46.75/H_BASE*SCREEN_H)];
    
    
    num2.textColor = COLORRGBA(153, 153, 153, 1);
    
    num2.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:num2];
    
    package2 = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(num2.frame)+5.0/H_BASE*SCREEN_H, CGRectGetWidth(num2.frame), CGRectGetHeight(num2.frame))];
    
    
    package2.textColor = COLORRGBA(153, 153, 153, 1);
    
    package2.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:package2];
    
    
    weight2 = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(num2.frame)+90.0/W_BASE*SCREEN_W, CGRectGetMinY(num2.frame), 300.0/W_BASE*SCREEN_W, CGRectGetHeight(num2.frame))];
    
    
    weight2.textColor = COLORRGBA(153, 153, 153, 1);
    
    weight2.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:weight2];
    
    
    
    tiji2 = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(weight2.frame), CGRectGetMaxY(weight2.frame), CGRectGetWidth(weight2.frame), CGRectGetHeight(weight2.frame))];
    
    
    tiji2.font = [UIFont systemFontOfSize:fontsize];
    
    tiji2.textColor = COLORRGBA(153, 153, 153, 1);
    
    [goodsview addSubview:tiji2];

    
    UIView * breakline2 = [[UIView alloc]initWithFrame:CGRectMake(0, (285.0+215.0)/H_BASE*SCREEN_H, SCREEN_W, 1)];
    
    breakline2.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [goodsview addSubview:breakline2];

    
    goodsname3 = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(breakline2.frame), 370.0/W_BASE*SCREEN_W, 82.0/H_BASE*SCREEN_H)];
    
    
    goodsname3.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:goodsname3];
    
    
    UIView * spaceview6 = [[UIView alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(goodsname3.frame), SCREEN_W - begin_x*2, 1)];
    
    spaceview6.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [goodsview addSubview:spaceview6];
    
    num3 = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(spaceview6.frame)+16.75/H_BASE*SCREEN_H, 250.0/W_BASE*SCREEN_W, 46.75/H_BASE*SCREEN_H)];
    
    
    num3.textColor = COLORRGBA(153, 153, 153, 1);
    
    num3.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:num3];
    
    package3 = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(num3.frame)+5.0/H_BASE*SCREEN_H, CGRectGetWidth(num3.frame), CGRectGetHeight(num3.frame))];
    
    
    package3.textColor = COLORRGBA(153, 153, 153, 1);
    
    package3.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:package3];
    
    
    weight3 = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(num3.frame)+90.0/W_BASE*SCREEN_W, CGRectGetMinY(num3.frame), 300.0/W_BASE*SCREEN_W, CGRectGetHeight(num3.frame))];
    
    
    weight3.textColor = COLORRGBA(153, 153, 153, 1);
    
    weight3.font = [UIFont systemFontOfSize:fontsize];
    
    [goodsview addSubview:weight3];
    
    
    
    tiji3 = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(weight3.frame), CGRectGetMaxY(weight3.frame), CGRectGetWidth(weight3.frame), CGRectGetHeight(weight3.frame))];
    
    
    tiji3.font = [UIFont systemFontOfSize:fontsize];
    
    tiji3.textColor = COLORRGBA(153, 153, 153, 1);
    
    [goodsview addSubview:tiji3];

  
    
    
    
    //增值服务
    
    zengzhiserver = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(goodsview.frame), SCREEN_W, 234.0/H_BASE*SCREEN_H)];
    
    zengzhiserver.backgroundColor = [UIColor whiteColor];
    
    [detailscrollview addSubview:zengzhiserver];
    
    UIView * titleview2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, 80.0/H_BASE*SCREEN_H)];
    
    titleview2.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [zengzhiserver addSubview:titleview2];
    
    UILabel * titlelable2 = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, 0, SCREEN_W-2*begin_x, 80.0/H_BASE*SCREEN_H)];
    
    titlelable2.text = @"增值服务";
    
    [zengzhiserver addSubview:titlelable2];
    
    titlelable2.font = [UIFont systemFontOfSize:fontsize -1 ];
    
    UILabel * shoustyle = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(titlelable2.frame), 160.0/W_BASE*SCREEN_W, 90.0/H_BASE*SCREEN_H)];
    
    shoustyle.text = @"收货方式";
    
    [zengzhiserver addSubview:shoustyle];
    
    shoustyle.font = [UIFont systemFontOfSize:fontsize];
    
    
    shouhuostyle = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_W - 100.0/W_BASE*SCREEN_W-34.0/W_BASE*SCREEN_W, CGRectGetMinY(shoustyle.frame), 100.0/W_BASE*SCREEN_W, CGRectGetHeight(shoustyle.frame))];
    
    
    [zengzhiserver addSubview:shouhuostyle];
    
    shouhuostyle.font = [UIFont systemFontOfSize:fontsize];
    
  //  phone.backgroundColor = [UIColor purpleColor];
    
    UILabel * styleicon = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(shouhuostyle.frame)-30.0/W_BASE*SCREEN_W, CGRectGetMinY(shouhuostyle.frame)+30.0/H_BASE*SCREEN_H, 30.0/W_BASE*SCREEN_W, 30.0/W_BASE*SCREEN_W)];
    
    styleicon.font = [UIFont fontWithName:@"iconfont" size:fontsize];
    
    styleicon.textColor = COLORRGBA(51, 204, 102, 1);
    
    styleicon.text = @"\U0000e669";
    
    [zengzhiserver addSubview:styleicon];
    
    
    UIView * spaceview2 = [[UIView alloc]initWithFrame:CGRectMake(begin_x,CGRectGetMaxY(shoustyle.frame), SCREEN_W - 2*begin_x, 1)];
    
    spaceview2.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [zengzhiserver addSubview:spaceview2];
    
    daishougoodsprice = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(spaceview2.frame), CGRectGetWidth(num.frame)+40.0/W_BASE*SCREEN_W, 58.3/H_BASE*SCREEN_H)];
   
    daishougoodsprice.font = [UIFont systemFontOfSize:fontsize];
    
    [zengzhiserver addSubview:daishougoodsprice];
    
//    wuliubao = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(daishougoodsprice.frame), CGRectGetWidth(daishougoodsprice.frame), CGRectGetHeight(daishougoodsprice.frame))];
//    
//    
//    wuliubao.font = [UIFont systemFontOfSize:fontsize];
//    
//    [zengzhiserver addSubview:wuliubao];
//    
//    goodsprice = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(wuliubao.frame), CGRectGetWidth(wuliubao.frame), CGRectGetHeight(wuliubao.frame))];
//    
//    
//    goodsprice.font = [UIFont systemFontOfSize:fontsize];
//    
//    [zengzhiserver addSubview:goodsprice];
    
    
    goodsprice.textColor = COLORRGBA(153, 153, 153, 1);
    wuliubao.textColor = COLORRGBA(153, 153, 153, 1);
    daishougoodsprice.textColor = COLORRGBA(153, 153, 153, 1);

    daishouprice = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(weight.frame), CGRectGetMinY(daishougoodsprice.frame), CGRectGetWidth(weight.frame), CGRectGetHeight(weight.frame))];
    
    
    daishouprice.font = [UIFont systemFontOfSize:fontsize];
    
    [zengzhiserver addSubview:daishouprice];
    
    daishouprice.textColor = COLORRGBA(153, 153, 153, 1);
    
    
    baoxianprice = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(daishouprice.frame), CGRectGetMinY(goodsprice.frame), CGRectGetWidth(weight.frame), CGRectGetHeight(weight.frame))];
    
    baoxianprice.textColor = COLORRGBA(153, 153, 153, 1);
    
    baoxianprice.font = [UIFont systemFontOfSize:fontsize];
    
    
    [zengzhiserver addSubview:baoxianprice];
    
    
    //费用明细
    
    feiyongview = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(zengzhiserver.frame), SCREEN_W, 290.0/H_BASE*SCREEN_H)];
    
    feiyongview.backgroundColor = [UIColor whiteColor];
    
    [detailscrollview addSubview:feiyongview];
    
    UIView * titleview3 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, 80.0/H_BASE*SCREEN_H)];
    
    titleview3.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [feiyongview addSubview:titleview3];
    
    UILabel * titlelab3 = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, 0, SCREEN_W - 2*begin_x, 80.0/H_BASE*SCREEN_H)];
    
    titlelab3.text = @"费用明细";
    
    [feiyongview addSubview:titlelab3];
    
    titlelab3.font = [UIFont systemFontOfSize:fontsize - 1];
    
    yunfei = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(titlelab.frame), 300./W_BASE*SCREEN_W, 80.0/H_BASE*SCREEN_H)];
    
    
    yunfei.font = [UIFont systemFontOfSize:fontsize];
    
    [feiyongview addSubview:yunfei];
    
    UIView * spaceview3 = [[UIView alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(yunfei.frame), SCREEN_W - 2*begin_x, 1)];
    
    spaceview3.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [feiyongview addSubview:spaceview3];
    
    xianfu = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(spaceview3.frame), CGRectGetWidth(daishougoodsprice.frame), 61.6/H_BASE*SCREEN_H)];
    
    
    xianfu.font = [UIFont systemFontOfSize:fontsize];
    
    xianfu.textColor = COLORRGBA(153, 153, 153, 1);
    
    [feiyongview addSubview:xianfu];
    
    huidan = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(xianfu.frame), CGRectGetWidth(xianfu.frame), CGRectGetHeight(xianfu.frame))];
    
    
    huidan.textColor = COLORRGBA(153, 153, 153, 1);
    
    huidan.font = [UIFont systemFontOfSize:fontsize];
    
    [feiyongview addSubview:huidan];
    
    qianfu = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(daishouprice.frame), CGRectGetMinY(xianfu.frame), CGRectGetWidth(daishouprice.frame), CGRectGetHeight(xianfu.frame))];
    
    qianfu.font = [UIFont systemFontOfSize:fontsize];
    
    qianfu.textColor = COLORRGBA(153, 153, 153, 1);
    
    
    [feiyongview addSubview:qianfu];

    daofu = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(qianfu.frame), CGRectGetMinY(huidan.frame), CGRectGetWidth(daishouprice.frame), CGRectGetHeight(qianfu.frame))];
 
    daofu.font = [UIFont systemFontOfSize:fontsize];
    
    daofu.textColor = COLORRGBA(153, 153, 153, 1);
    
    [feiyongview addSubview:daofu];
    
    
//    huifu = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(qianfu.frame), CGRectGetMinY(huidan.frame), CGRectGetWidth(daishouprice.frame), CGRectGetHeight(qianfu.frame))];
//    huifu.textColor = COLORRGBA(153, 153, 153, 1);
//    huifu.font = [UIFont systemFontOfSize:fontsize];
//    [feiyongview addSubview:huifu];
    
    //返款信息 150
    
    fankuanview = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(feiyongview.frame), SCREEN_W, 0.0/H_BASE*SCREEN_H)];
    fankuanview.backgroundColor = [UIColor whiteColor];
    [detailscrollview addSubview:fankuanview];
    
    UIView * titleview4 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, 70.0/H_BASE*SCREEN_H)];
    
    titleview4.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [fankuanview addSubview:titleview4];
    
    UILabel * titlelab4 = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, 0, SCREEN_W, 70.0/H_BASE*SCREEN_H)];
    
    titlelab4.text = @"返款信息";
    
    titlelab4.font = [UIFont systemFontOfSize:fontsize - 1];
    
    [fankuanview addSubview:titlelab4];
    
    
    fankuan = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(titlelab4.frame), CGRectGetWidth(daofu.frame), 80.0/H_BASE*SCREEN_H)];
    
    
    fankuan.font = [UIFont systemFontOfSize:fontsize];
    
    [fankuanview addSubview:fankuan];
    
    qianfan = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(huifu.frame), CGRectGetMinY(fankuan.frame), CGRectGetWidth(huifu.frame), 80.0/H_BASE*SCREEN_H)];
    
    qianfan.font = [UIFont systemFontOfSize:fontsize];
    
    
    [fankuanview addSubview:qianfan];
    
    
    
    //备注

    
    
    remarkview = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(fankuanview.frame), SCREEN_W, 150.0/H_BASE*SCREEN_H)];

    
    
    remarkview.backgroundColor = [UIColor whiteColor];
    
    [detailscrollview addSubview:remarkview];
    
    UIView * titleview5 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, 70.0/H_BASE*SCREEN_H)];
    
    titleview5.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    [remarkview addSubview:titleview5];
    
    UILabel * titlelab5 = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, 0, SCREEN_W, 70.0/H_BASE*SCREEN_H)];
    
    titlelab5.text = @"备注";
    
    titlelab5.font = [UIFont systemFontOfSize:fontsize - 1];
    
    [remarkview addSubview:titlelab5];


    
    remark = [[UILabel alloc]initWithFrame:CGRectMake(begin_x, CGRectGetMaxY(titlelab4.frame), CGRectGetWidth(daofu.frame), 80.0/H_BASE*SCREEN_H)];
    
    
    remark.font = [UIFont systemFontOfSize:fontsize];
    
    [remarkview addSubview:remark];
    
    
    
    
    
    
    
    
 
    
    
    
    
    
    
    
    
    
    
    
    

}

#pragma mark - -- - - - -- -  运单跟踪界面 - -- - - - -- - - - -

- (void)createFollowScrollview{

    float fontsize = 14;
    
    fontsize = SCREEN_H < 667 ? 12 : 16;
    
    if (SCREEN_H == 667) {
        
        fontsize = 14;
    }

    followscrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(SCREEN_W, 18.0/H_BASE*SCREEN_H, SCREEN_W, CGRectGetHeight(scrollview.frame))];
    
    followscrollview.backgroundColor = COLORRGBA(238, 238, 238, 1);
    
    [scrollview addSubview:followscrollview];
    
    followscrollview.showsVerticalScrollIndicator = NO;
    
    followscrollview.showsHorizontalScrollIndicator = NO;
    
    followscrollview.pagingEnabled = YES;
    
    followscrollview.delegate = self;
    
    // 设置大小
    
    followscrollview.contentSize = CGSizeMake(SCREEN_W, 1200.0/H_BASE*SCREEN_H);
    //运单view
    follow_docuview= [[UIView alloc]initWithFrame:CGRectMake(6.0/W_BASE*SCREEN_W, 0, 744.0/W_BASE*SCREEN_W, 204.0/H_BASE*SCREEN_H)];
//    docuview.backgroundColor = [UIColor yellowColor];
    
    [followscrollview addSubview:follow_docuview];
    
    follow_docuview.layer.cornerRadius = 2;
    
    follow_docuview.clipsToBounds = YES;
    
    UIImageView * im = [[UIImageView alloc]initWithFrame:docuview.bounds];
    
    im.image = [UIImage imageNamed:@"docuback.png"];
    
    [follow_docuview addSubview:im];
    
    follow_doculabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0/W_BASE*SCREEN_W, 14.0/H_BASE*SCREEN_H, CGRectGetWidth(docuview.frame) - 40.0/W_BASE*SCREEN_W, 60.0/H_BASE*SCREEN_H)];
    
    follow_doculabel.textColor = [UIColor whiteColor];
    
    
    follow_doculabel.font = [UIFont boldSystemFontOfSize:fontsize];
    
    [follow_docuview addSubview:follow_doculabel];
    
    UIImageView * iconimage = [[UIImageView alloc]initWithFrame:CGRectMake(22.0/W_BASE*SCREEN_W, CGRectGetMaxY(doculabel.frame)+24.0/H_BASE*SCREEN_H, 18.0/W_BASE*SCREEN_W, 64.0/H_BASE*SCREEN_H)];
    
    iconimage.image = [UIImage imageNamed:@"startline.png"];
    
    [follow_docuview addSubview:iconimage];
    
    
    follow_startplace = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(iconimage.frame)+12.0/W_BASE*SCREEN_W, CGRectGetMaxY(doculabel.frame)+5.0/H_BASE*SCREEN_H, 200.0/W_BASE*SCREEN_W, 60.0/H_BASE*SCREEN_H)];
    
    
    follow_startplace.font = [UIFont systemFontOfSize:fontsize - 1];
    
    [follow_docuview addSubview:follow_startplace];
    
    follow_endplace = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(iconimage.frame)+12.0/W_BASE*SCREEN_W, CGRectGetMaxY(startplace.frame)-10.0/H_BASE*SCREEN_H, 200.0/W_BASE*SCREEN_W, 60.0/H_BASE*SCREEN_H)];
    
    
    follow_endplace.font = [UIFont systemFontOfSize:fontsize - 1];
    
    [follow_docuview addSubview:follow_endplace];
    
    
    follow_nameandTime = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(startplace.frame)+ 160.0/W_BASE*SCREEN_W, CGRectGetMinY(startplace.frame), 305.0/W_BASE*SCREEN_W, CGRectGetHeight(startplace.frame))];
    
//    follow_company.backgroundColor = [UIColor yellowColor];
    
    
    follow_nameandTime.font = [UIFont systemFontOfSize:fontsize - 1];
    
    [follow_docuview addSubview:follow_nameandTime];
    
    follow_nameandTime.textAlignment = NSTextAlignmentRight;
    
    follow_nameandTime.textColor = COLORRGBA(204, 204, 204, 1);
    
    follow_company = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(startplace.frame)+ 160.0/W_BASE*SCREEN_W, CGRectGetMinY(endplace.frame), 305.0/W_BASE*SCREEN_W, CGRectGetHeight(startplace.frame))];
    
//    follow_company.backgroundColor = [UIColor purpleColor];
    
    follow_company.textAlignment = NSTextAlignmentRight;
    follow_company.font = [UIFont systemFontOfSize:fontsize - 1];
    [follow_docuview addSubview:follow_company];
    company.textAlignment = NSTextAlignmentRight;
    
    //创建跟踪view
    UIView * jinduview = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(follow_docuview.frame)+30.0/H_BASE*SCREEN_H, SCREEN_W, CGRectGetHeight(followscrollview.frame)- CGRectGetHeight(follow_docuview.frame))];
    jinduview.backgroundColor = COLORRGBA(239, 239, 239, 1);
    [followscrollview addSubview:jinduview];
    maxY = CGRectGetMinY(jinduview.frame);
}

- (void)addFollowViews {
    float fontsize = 14;
    
    fontsize = SCREEN_H < 667 ? 12 : 16;
    
    if (SCREEN_H == 667) {
        
        fontsize = 14;
    }

    followscrollview.contentSize = CGSizeMake(SCREEN_W, 100.0/H_BASE*SCREEN_H*self.followarr.count+234.0/H_BASE*SCREEN_H);
    
    UIView * backView = ({
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, maxY, SCREEN_W, 100 * self.followarr.count * SCREEN_H/H_BASE)];
        view.backgroundColor = [UIColor whiteColor];
        view;
    });
    [followscrollview addSubview:backView];
    for (int i = 0; i < self.followarr.count; i++) {
        
        UIView * firstRect = [[UIView alloc] initWithFrame:CGRectMake(28.0/W_BASE*SCREEN_W, maxY + i * 100/H_BASE*SCREEN_H+24/H_BASE*SCREEN_H, 18/W_BASE*SCREEN_W, 18/H_BASE*SCREEN_H)];
        firstRect.layer.cornerRadius = 9/H_BASE*SCREEN_H;
        [followscrollview addSubview:firstRect];
        
        
        NSInteger length = (i == self.followarr.count - 1) ? 30 : 100;
        UIView * leftline = [[UIView alloc] initWithFrame:CGRectMake(37.0/W_BASE*SCREEN_W, maxY + i * 100/H_BASE*SCREEN_H, 1.0/W_BASE*SCREEN_W, length/H_BASE*SCREEN_H)];
        leftline.backgroundColor =COLORRGBA(204, 204, 204, 1);
        
        [followscrollview addSubview:leftline];
        
        UIView * secondRect = [[UIView alloc] initWithFrame:CGRectMake(30.0/W_BASE*SCREEN_W, CGRectGetMinY(leftline.frame)+26/H_BASE*SCREEN_H, 14/W_BASE*SCREEN_W, 14/H_BASE*SCREEN_H)];
        secondRect.layer.cornerRadius = 7/H_BASE*SCREEN_H;
        [followscrollview addSubview:secondRect];
        
        UIView * bottomLine = [[UIView alloc] initWithFrame:CGRectMake(70.0/W_BASE*SCREEN_W, CGRectGetMinY(leftline.frame) + 99.0/H_BASE*SCREEN_H, SCREEN_W-70.0/W_BASE*SCREEN_W, 1.0/H_BASE*SCREEN_H)];
        bottomLine.backgroundColor = COLORRGBA(204, 204, 204, 1);
        [followscrollview addSubview:bottomLine];
        
        UILabel * content = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(bottomLine.frame), CGRectGetMinY(firstRect.frame), CGRectGetWidth(bottomLine.frame), 25.0/H_BASE*SCREEN_H)];
        content.text = self.followarr[i][@"content"];
        content.font = [UIFont systemFontOfSize:fontsize];
        [followscrollview addSubview:content];
        
        UILabel * time = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(bottomLine.frame), CGRectGetMaxY(content.frame)+13/H_BASE*SCREEN_H, CGRectGetWidth(bottomLine.frame), CGRectGetHeight(content.frame))];
        time.text = self.followarr[i][@"time"];
        time.textColor = COLORRGBA(204, 204, 204, 1);
        time.font = [UIFont systemFontOfSize:fontsize];
        [followscrollview  addSubview:time];
    
        if (i == 0) {
            leftline.frame = CGRectMake(37.0/W_BASE*SCREEN_W, CGRectGetMinY(secondRect.frame), 1.0/W_BASE*SCREEN_W, 100/H_BASE*SCREEN_H - 26/H_BASE*SCREEN_H);
            firstRect.backgroundColor = COLORRGBA(197, 239, 212, 1);
            secondRect.backgroundColor = COLORRGBA(61, 202, 106, 1);
        }
        else {
            firstRect.backgroundColor = [UIColor whiteColor];
            secondRect.backgroundColor = COLORRGBA(204, 204, 204, 1);
        }
        
//        if (i == self.followarr.count - 1) {
//            leftline.backgroundColor = [UIColor whiteColor];
//        }
        
        
        
    }
}


#pragma mark - -- - - - -- - -  Action - -- - - - - - -- - -

- (void)phoneNow:(UIButton *)btn{


    NSLog(@"phonenow");
    
    if (btn.tag == 7000) {
        
        // 打电话
        
        NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phone.text];
        
        NSLog(@"phone str %@",str);
        
        UIWebView * callWebview = [[UIWebView alloc] init];
        
        [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
        
        [self.view addSubview:callWebview];
        

        
    }else{
    
    
        NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",shouhuophone.text];
        
        NSLog(@"phone str %@",str);

        UIWebView * callWebview = [[UIWebView alloc] init];
        
        [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
        
        [self.view addSubview:callWebview];

    
    }







}

- (void)enterClick:(UIButton *)btn{
    
    
    NSInteger tag = btn.tag;
    
    switch (tag) {
            
        case return_tag:
            
            
//            [self.navigationController popViewControllerAnimated:YES];
            [self dismissViewControllerAnimated:YES completion:nil];
            
            
            break;
            
        case search_tag:
            
            
            //进入筛选界面
            
            NSLog(@"运单加入收藏");
            
            
            break;
            
        case docudetail_tag:
            
            
            //运单详情
            
            [self scrollbtnMove:YES];
            
            
            break;
            
        case docufollow_tag:
            
            //运单跟踪
            
            [self scrollbtnMove:NO];
            
            
            break;
            
            
        default:
            break;
    }
    
    
    
    
}



#pragma mark  - -- - - - 点击按钮时，绿条跟着移动 － － － － － － －



- (void)scrollbtnMove:(BOOL)isFahuoMove{
    
    
    if (isFahuoMove) {
        
        NSLog(@"移到详情");
        
        //点击发货时，绿条在发货btn下面
        
        [UIView animateWithDuration:0.5 animations:^{
            
            CGRect rect1 = CGRectMake(130.0/W_BASE*SCREEN_W, CGRectGetMinY(scrollbtn.frame), CGRectGetWidth(scrollbtn.frame), CGRectGetHeight(scrollbtn.frame));
            
            scrollbtn.frame = rect1;
            
            [docudetailbtn setTitleColor:COLORRGBA(81, 168, 255, 1) forState:UIControlStateNormal];
            
            [docudetailbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            
            scrollview.contentOffset = CGPointMake(0, 0);
            
            
        } completion:^(BOOL finished) {
            
            
        }];
        
        
    }
    else{
        
        NSLog(@"移到跟踪");
        
        
        [UIView animateWithDuration:0.5 animations:^{
            
            //绿条在到货btn下面
            
            CGRect rect1 = CGRectMake(SCREEN_W * 0.5+ 130.0/W_BASE*SCREEN_W, CGRectGetMinY(scrollbtn.frame), CGRectGetWidth(scrollbtn.frame), CGRectGetHeight(scrollbtn.frame));
            
            scrollbtn.frame = rect1;
            
            [docudefollowbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            
            
            [docudefollowbtn setTitleColor:COLORRGBA(81, 168, 255, 1) forState:UIControlStateNormal];
            
            scrollview.contentOffset = CGPointMake(SCREEN_W, 0);
            
            
        } completion:^(BOOL finished) {
            
            
        }];
        
        
    }
    
    
}

#pragma mark  - -- - - - - - Scrollview Delegate 方法 － － － －－ －

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
    
    
    NSInteger page = scrollView.contentOffset.x / SCREEN_W;
    
    
    if (scrollView != scrollview) {
        
        
    }else{
    
        
    if (page * SCREEN_W == scrollView.contentOffset.x ) {
        
        //整页滑动
        
        if (page == 0) {
            
            
            [UIView animateWithDuration:0.5 animations:^{
                
                CGRect rect2 = CGRectMake(130.0/W_BASE*SCREEN_W, CGRectGetMinY(scrollbtn.frame), CGRectGetWidth(scrollbtn.frame), CGRectGetHeight(scrollbtn.frame));
                
                scrollbtn.frame = rect2;
                
                [docudetailbtn setTitleColor:COLORRGBA(81, 168, 255, 1) forState:UIControlStateNormal];
                
                [docudefollowbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                
                
            } completion:^(BOOL finished) {
                
            }];
            
            
        }
        else if(page == 1){
            
            
            [UIView animateWithDuration:0.5 animations:^{
                
                //绿条在到货btn下面
                
                CGRect rect1 = CGRectMake(SCREEN_W * 0.5+ 130.0/W_BASE*SCREEN_W, CGRectGetMinY(scrollbtn.frame), CGRectGetWidth(scrollbtn.frame), CGRectGetHeight(scrollbtn.frame));
                
                scrollbtn.frame = rect1;
                
                
                [docudetailbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                
                
                [docudefollowbtn setTitleColor:COLORRGBA(81, 168, 255, 1) forState:UIControlStateNormal];
                
                
            } completion:^(BOOL finished) {
                
                
            }];
            
        }
        
    }
    }
    
}


- (AFHTTPSessionManager*)manger{
    
    _manger = [AFHTTPSessionManager manager];
    
    _manger.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    _manger.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"application/json", nil];
    
    return _manger;
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
